defmodule House.BasicDataTest do
  use House.DataCase

  alias House.BasicData
  alias House.BasicData.Item

  @create_attrs %{address: "some address", around: "some around", bedroom: "120.5", fitment: "some fitment", floor: 42, gps: "some gps", heating: "some heating", investment: "some investment", kitchen: "120.5", license: "some license", livingroom: "120.5", loan: "some loan", name: "some name", noise: "some noise", service: "some service", stop: "some stop", summary: "some summary", sunshine: "some sunshine", terrace: "120.5", traffic: "some traffic", year: 42}
  @update_attrs %{address: "some updated address", around: "some updated around", bedroom: "456.7", fitment: "some updated fitment", floor: 43, gps: "some updated gps", heating: "some updated heating", investment: "some updated investment", kitchen: "456.7", license: "some updated license", livingroom: "456.7", loan: "some updated loan", name: "some updated name", noise: "some updated noise", service: "some updated service", stop: "some updated stop", summary: "some updated summary", sunshine: "some updated sunshine", terrace: "456.7", traffic: "some updated traffic", year: 43}
  @invalid_attrs %{address: nil, around: nil, bedroom: nil, fitment: nil, floor: nil, gps: nil, heating: nil, investment: nil, kitchen: nil, license: nil, livingroom: nil, loan: nil, name: nil, noise: nil, service: nil, stop: nil, summary: nil, sunshine: nil, terrace: nil, traffic: nil, year: nil}

  def fixture(:item, attrs \\ @create_attrs) do
    {:ok, item} = BasicData.create_item(attrs)
    item
  end

  test "list_items/1 returns all items" do
    item = fixture(:item)
    assert BasicData.list_items() == [item]
  end

  test "get_item! returns the item with given id" do
    item = fixture(:item)
    assert BasicData.get_item!(item.id) == item
  end

  test "create_item/1 with valid data creates a item" do
    assert {:ok, %Item{} = item} = BasicData.create_item(@create_attrs)
    assert item.address == "some address"
    assert item.around == "some around"
    assert item.bedroom == "120.5"
    assert item.fitment == "some fitment"
    assert item.floor == 42
    assert item.gps == "some gps"
    assert item.heating == "some heating"
    assert item.investment == "some investment"
    assert item.kitchen == "120.5"
    assert item.license == "some license"
    assert item.livingroom == "120.5"
    assert item.loan == "some loan"
    assert item.name == "some name"
    assert item.noise == "some noise"
    assert item.service == "some service"
    assert item.stop == "some stop"
    assert item.summary == "some summary"
    assert item.sunshine == "some sunshine"
    assert item.terrace == "120.5"
    assert item.traffic == "some traffic"
    assert item.year == 42
  end

  test "create_item/1 with invalid data returns error changeset" do
    assert {:error, %Ecto.Changeset{}} = BasicData.create_item(@invalid_attrs)
  end

  test "update_item/2 with valid data updates the item" do
    item = fixture(:item)
    assert {:ok, item} = BasicData.update_item(item, @update_attrs)
    assert %Item{} = item
    assert item.address == "some updated address"
    assert item.around == "some updated around"
    assert item.bedroom == "456.7"
    assert item.fitment == "some updated fitment"
    assert item.floor == 43
    assert item.gps == "some updated gps"
    assert item.heating == "some updated heating"
    assert item.investment == "some updated investment"
    assert item.kitchen == "456.7"
    assert item.license == "some updated license"
    assert item.livingroom == "456.7"
    assert item.loan == "some updated loan"
    assert item.name == "some updated name"
    assert item.noise == "some updated noise"
    assert item.service == "some updated service"
    assert item.stop == "some updated stop"
    assert item.summary == "some updated summary"
    assert item.sunshine == "some updated sunshine"
    assert item.terrace == "456.7"
    assert item.traffic == "some updated traffic"
    assert item.year == 43
  end

  test "update_item/2 with invalid data returns error changeset" do
    item = fixture(:item)
    assert {:error, %Ecto.Changeset{}} = BasicData.update_item(item, @invalid_attrs)
    assert item == BasicData.get_item!(item.id)
  end

  test "delete_item/1 deletes the item" do
    item = fixture(:item)
    assert {:ok, %Item{}} = BasicData.delete_item(item)
    assert_raise Ecto.NoResultsError, fn -> BasicData.get_item!(item.id) end
  end

  test "change_item/1 returns a item changeset" do
    item = fixture(:item)
    assert %Ecto.Changeset{} = BasicData.change_item(item)
  end
end
